<template>
    <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="普通登录" name="first">普通登录</el-tab-pane>

            <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="姓名">
                <el-input v-model="form.name"></el-input>
            </el-form-item>

            <el-input placeholder="请输入密码" v-model="form.password" show-password></el-input>


            <el-form-item label="活动时间">
                <el-col :span="11">
                  <el-input placeholder="密码再一次校验" v-model="form.password"></el-input>
                </el-col>
                <el-col class="line" :span="2">-</el-col>
                <el-col :span="11">

                 <img src="http://demo.ruoyi.vip/captcha/captchaImage?type=math&s=0.2661691542964031" alt="">
                 
                </el-col>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="onSubmit()">登录</el-button>
            
            </el-form-item>
            </el-form>

    <el-tab-pane label="手机登录" name="second">手机登录</el-tab-pane>
    <el-tab-pane label="其他登录" name="third">其他登录</el-tab-pane>
    

  </el-tabs>
 
 
 
 </div>
</template>

<script>
 export default {
    data() {
      return {
        activeName: 'first',
         form: {
          name: 'admin',
          password: 'admin'
        }

      };
    },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event);
      },
    onSubmit(){
    
    
    axios.post(this.$baseUrl + '/user/login', this.form).then(res => {
        if (res.data.flag) {

          // 将token 存入localStorage
          let userInfo = res.data.data
          window.localStorage.setItem("token", userInfo.token);
            alert(userInfo.name);
              alert(userInfo.password);
         
         this.$store.commit('setInfo', userInfo)
          this.$router.push("/")
        } else {
          alert(res.data.msg)
        }

      })
    }
    }
  };
</script>



